<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Resource Timing TAO tests</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="https://www.w3.org/TR/resource-timing-2/#timing-allow-origin"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/webperftestharness.js"></script>
<script src="resources/webperftestharnessextension.js"></script>
<script>
setup({explicit_done: true});

// Explicitly test the namespace before we start testing.
test_namespace('getEntriesByType');

let iframe;
function setup_iframe() {
    iframe = document.getElementById('frameContext');
    iframe.addEventListener('load', onload_test, false);
}
function onload_test() {
    if (window.performance.getEntriesByType === undefined) {
      done();
      return;
    }
    const context = new PerformanceContext(iframe.contentWindow.performance);
    const entries = context.getEntriesByType('resource');

    test_equals(entries.length, 1, 'The iframe should have one resource timing entry.');
    const entry = entries[0];
    test_equals(entry.redirectStart, 0, 'redirectStart should be 0 in cross-origin request since no redirect.');
    test_equals(entry.redirectEnd, 0, 'redirectEnd should be 0 in cross-origin request since no redirect.');
    test_greater_than(entry.domainLookupStart, 0, 'domainLookupStart should not be 0 in timing-allow cross-origin request.');
    test_greater_than(entry.domainLookupEnd, 0, 'domainLookupEnd should not be 0 in timing-allow cross-origin request.');
    test_greater_than(entry.connectStart, 0, 'connectStart should not be 0 in timing-allow cross-origin request.');
    test_greater_than(entry.connectEnd, 0, 'connectEnd should not be 0 in timing-allow cross-origin request.');
    test_greater_than(entry.requestStart, 0, 'requestStart should not be 0 in timing-allow cross-origin request.');
    test_greater_than(entry.responseStart, 0, 'responseStart should not be 0 in timing-allow cross-origin request.');
    test_equals(entry.secureConnectionStart, 0, 'secureConnectionStart should be 0 in cross-origin request since no ssl!');
    test_greater_than(entry.fetchStart, 0, 'fetchStart should not be 0 in timing-allow cross-origin request.');
    test_greater_than(entry.responseEnd, 0, 'responseEnd should not be 0 in timing-allow cross-origin request.');
    done();
}
window.setup_iframe = setup_iframe;
</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates that for a cross origin resource, the timing allow check algorithm will pass when the value of Timing-Allow-Origin is a case-sensitive match for the value of the origin of the current document.</p>
<div id="log"></div>
<iframe id="frameContext" src="resources/iframe_TAO_origin.html"></iframe>
</body>
</html>
